- /* sfmfput.cpp by K.Tsuru */
- // function ID = 740 DARDIX
- /**************************
- SFraction class
- It provides the output.
- **************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- ///////////////////////////////////////
- // declared as long Put(long fig=5, char delmt=' ', int fmt = BRACKET); in "sfract.h"
- int SFraction::lineFormat = SFraction::BRACKET; // Set by BRACKET | END_CR | MID_CR. Set "BRACKET" in default
- long SFraction::ioCount = 0;
- void SFraction::SetFormat(int fmt) { // The format of Num() and Den() obey that of SLong.
- lineFormat = fmt;
- }
- long SFraction::Put(int fmt) {
- lineFormat = fmt; ioCount = 0;
- Reduce();
- long p = 0;
- if(lineFormat & BRACKET){
- num.FPutc('('); p = 2; // ()
- }
- // in SLong class long Put(long fig=5, int perLine = 0, int lineFormat = CRLF, int delmt=' ') const; // 261
- if( den.IsOne() ){ //denominator=1
- p += num.Put(num.figUnit, num.perLine, num.lineFormat, num.delmt);
- } else {
- p += num.Put(num.figUnit, num.perLine, num.lineFormat, num.delmt);
- num.FPutc('/'); p++;
- if(lineFormat & MID_CR) { num.FPutc('\n'); p++; }
- p += den.Put(num.figUnit, num.perLine, num.lineFormat, num.delmt);
- }
- if(lineFormat & BRACKET) {
- num.FPutc(')'); p++;
- }
- if(lineFormat & END_CR) {
- num.FPutc('\n'); p++;
- }
- return ioCount = p;
- }
sfmfput.cpp : last modifiled at 2017/10/23 11:02:13(1,281 bytes)
created at 2015/12/22 16:07:29
The creation time of this html file is 2017/10/23 11:26:54 (Mon Oct 23 11:26:54 2017).